@extends('layouts.header')
@section('title','退押金')
@section('content')
    <div class="deviceService">
        <div class="malfunction">
            <div class="malfunctionTitle">选择退押金原因</div>
            <div class="malfunctionArea malfunctionOne" id="malfunctionOne">
                @foreach($types as $type)
                    <div @if($loop->first) class="active"
                         @endif data-malfunction="{{$type->id}}">{{$type->type_name}}</div>
                @endforeach
            </div>
        </div>
        <div class="malfunction">
            <div class="malfunctionTitle">简述退押金理由</div>
            <div class="malfunctionArea malfunctionAreaThree">
                <textarea id="text" name="refund_desc" form="form"></textarea>
            </div>
        </div>
        <div class="malfunction">
            <div class="malfunctionTitle">退押金须知：</div>
            <div class="xuzhi">
                退款申请提交后，我们会在1-7日内审核及核实后，
                给予结果。谢谢您的使用，希望再次合作。
                注：押金退还后，您和您的成员将不能正常使用！
            </div>
        </div>
        <div class="sub">
            <button id="submit">提交申请</button>
        </div>
    </div>
    <form id="form" action="{{route('deposit.refund',['id'=>$group->id])}}" method="post">
        {{ csrf_field() }}
        <input id="refund_type" type="hidden" name="type_id" value="">
        <input id="refund_desc" type="hidden" name="refund_desc">
    </form>
@endsection
@push('js')
    <script>
        var obj = new MyObj();

        function MyObj() {
            this.malfunction = 1;			// 故障状态码
        }

        $("#replace").click(function () {
            $("#cabinetTwo").show();
        });
        $("#malfunctionOne div").click(function () {
            var refundType = parseInt($(this).attr("data-malfunction"));
            $('#refund_type').val(refundType);
            $(this).addClass("active").siblings().removeClass("active");
        });
        $("#submit").click(function () {
            if (obj.malfunction == null || obj.malfunction == undefined) {
                mui.alert("请选择退押金原因", "提示", "确认");
                return false;
            }
            var handleWay = $('#handle_way').val();
            var gripId = $('#grip_id').val();
            var refundType = $('#refund_type').val();
            var refund_desc = $('#text').val();
            $('#refund_desc').val(refund_desc);

            if (refundType == null || refundType == undefined) {
                mui.alert("请选择故障类型", "提示", "确认");
                return false;
            }
            /*  mui.alert("感谢您的反馈, 我们会尽快维修。", "提交完成", "确认");*/
            $('#form').submit();
            return false;

        });

    </script>
@endpush
